<template>
    <div class="supplier-products">
        <fs-crud ref="crudRef" v-bind="crudBinding"></fs-crud>
    </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref, computed, PropType } from 'vue';
import { useFs } from '@fast-crud/fast-crud';
import createCrudOptions from '../SupplierProduct/crud';

export default defineComponent({
    name: 'SupplierProducts',
    props: {
        supplier_id: {
            type: String as PropType<string>,
            required: true
        }
    },
    setup(props) {
        // 注入supplier_id到crud配置
        const context = {
            props
        };

        const { crudBinding, crudRef, crudExpose } = useFs({ 
            createCrudOptions, 
            context
        });
        
        // 页面加载时刷新数据
        onMounted(() => {
            crudExpose.doRefresh();
        });

        return {
            crudBinding,
            crudRef
        };
    }
});
</script>

<style lang="scss" scoped>
.supplier-products {
    padding: 20px;
}
</style> 